package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.CheckWorkBean;
import com.fy.fyzf.bean.CheckWorkListBean;
import com.fy.fyzf.bean.CommonSearchBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.IsInfoBean;
import com.fy.fyzf.bean.RandomTextBean;
import com.fy.fyzf.bean.WorkLogBean;
import com.fy.fyzf.bean.WorkStepBean;
import com.fy.fyzf.view.CheckWorkCallBack;

import java.util.List;

public class CheckWorkPresenter extends BasePresenter<CheckWorkCallBack> {
    public CheckWorkPresenter(CheckWorkCallBack view) {
        super(view);
    }

    //上班
    public void addGoToWork(CheckWorkBean checkWorkBean){
        addSubscription(mApiService.addGoToWork(checkWorkBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.CheckWorkSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    //下班
    public void addOffWork(CheckWorkBean checkWorkBean){
        addSubscription(mApiService.addGoOffWork(checkWorkBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.CheckWorkSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    //下班
    public void addOutWork(CheckWorkBean checkWorkBean){
        addSubscription(mApiService.addGoOut(checkWorkBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.CheckWorkSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getCheckWorkList(CommonSearchBean commonSearchBean) {
        addSubscription(mApiService.checkWorkList(commonSearchBean), new SubscriberCallBack<BaseData<CheckWorkListBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<CheckWorkListBean> response) {
                mView.getCheckWorkListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getWorkStep(){
        addSubscription(mApiService.workingSteps(""), new SubscriberCallBack<BaseData<WorkStepBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<WorkStepBean> response) {
                mView.getWorkStepSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void addWorkLog(WorkLogBean workLogBean){
        addSubscription(mApiService.addWorkLog(workLogBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.addWorkLogSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getUserLocation(){
        addSubscription(mApiService.randDict(), new SubscriberCallBack<BaseData<RandomTextBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<RandomTextBean> response) {
                mView.getUserLocationSucccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void isInfo(){
        addSubscription(mApiService.isInfo(0), new SubscriberCallBack<BaseData<IsInfoBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<IsInfoBean> response) {
                mView.isInfoSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }
}
